﻿
/* 描述：用户表自定义方法
 * 创建人：商伟
 * 创建时间：2011-6-13
 * 修改人:
 * 修改时间：2011-6-13 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HGZP.DAL;
using HGZP.Model;
using HGZP.PLL;

namespace HGZP.BLL
{
    public partial class BaseUserBLL
    {

        /// <summary>
        /// 检查用户登录信息
        /// </summary>
        /// <param name="userName">用户账号</param>
        /// <param name="password">密码</param>
        /// <returns>sGuid:成功；1:登录失败;2:无此用户;3:口令错误"
        /// </returns>
        public string Exist(string userName, string password)
        {
            CBaseUserCollection myCBaseUserCollection = new CBaseUserCollection();
            CBaseUserBLL myBaseUserBll = new CBaseUserBLL();
            try
            {
                List<CBaseUser> userList = myCBaseUserCollection.F06_SelectEntityHaveWhereOrder(
                    string.Empty, string.Format("{0}='{1}' ", myBaseUserBll.sUserID, userName) + " AND " + string.Format("{0}='True' ", myBaseUserBll.bPublisher), string.Empty);

                if (userList.Count == 0)
                {

                    return "1,用户名或密码错误";
                }
                if (!userList.First().sPassWord.Trim().Equals(password.Trim()))
                {

                    return "2,用户名或密码错误";
                }
                return "3," + userList.First().sGuid;
            }
            catch (Exception ex)
            {
                return "4," + ex.Message.ToString();
            }

        }

        /// <summary>
        /// 根据用户ID取用户角色的功能
        /// </summary>
        /// <param name="userGuid">用户ID</param>
        /// <returns>用户功能集合</returns>
        public DataTable GetUserFunction(string userGuid)
        {
            BaseUserCollection myBaseUserCollection = new BaseUserCollection();
            return myBaseUserCollection.GetUserFuction(userGuid);

        }

        //
    }
}
